//onemax first choice shc problem-depended class
//$Id: onemax_shc.h 718 2012-06-04 17:02:38Z Oleg.Bulychov@gmail.com $
#pragma once

#include "projects/onemax/onemax.h"
#include "solvers/shc/shc_common.h"
//__________________________________________________________________________________
//__________________________________________________________________________________
template<>
struct solution<OneMax_Solution, shc_tag>:
    public OneMax_Solution
{
    typedef solution<OneMax_Solution, shc_tag> OneMax_Solution_SHC;
public:
    template<class E>
    void move(E* env, random_generator& rnd, double probability)
    {
        for (size_t i = 0; i < data_.size(); ++i)
        {
            if (rnd.next_Double() < probability)
            {
                data_[i] = !data_[i];
                changed_ = true;
            }
        }
    }
};



template<class E, class X>
void OneMax_History::update(int step, int rank, SHC<X>& s, E* env)
{
    SHC<X>::TSolution const& sol = s.get_Current_Solution();

    hist_[rank].sol_.resize(hist_[rank].sol_.size() + 1);
    std::vector<OneMax_Solution>& arr = hist_[rank].sol_.back();
    arr.resize(1);
    arr[0].init(env, random_generator(rank));
    arr[0].assign(sol);
}


//EOF!
